/*
 * @Author: Mr · Lei
 * @Date: 2025-01-04 18:12:30
 * @LastEditors: OBKoro1
 * @LastEditTime: 2025-01-04 19:05:23
 * @FilePath: \ruituan-tuan-Agent\src\api\dashboard.ts
 * @Description: 
 * 
 * Copyright (c) 2025 by 四川开局红科技有限公司, All Rights Reserved. 
 */

import axios from 'axios';
import { TableData } from '@/types/global';

export interface UserListRecord {
  id: number;
  nickname: string;
  mobile: string;
  avatar: string;
  createtime: string;
  // ... 其他字段根据需要添加
}

export interface UserListResponse {
  total: number;
  per_page: number;
  current_page: number;
  last_page: number;
  data: UserListRecord[];
}

export interface LineChartData {
  date: string;
  value: number;
}

export interface StatisticsResponse {
    user_number: number;
    shop_number: number;
    receive_number: number;
    profit_number: number;
}

export interface StatisticsData {
  user_number: number;
  shop_number: number;
  receive_number: number;
  profit_number: number;
}

export interface ShopStatisticsParams {
  page: number;
  limit: number;
  user_id?: number;
  shop_id?: number;
  start_time?: string;
  end_time?: string;
}

export interface ShopStatisticsRecord {
  shop_id: number;
  receive_number: string;
  shop: {
    id: number;
    name: string;
    logo: string;
    mobile: string;
    address: string;
  };
}

export interface ShopStatisticsResponse {
  receive_number: {
    total: number;
    per_page: number;
    current_page: number;
    last_page: number;
    data: ShopStatisticsRecord[];
  };
}

// 获取门店统计数据
export function getShopStatistics(params: ShopStatisticsParams) {
  return axios.get<ShopStatisticsResponse>('/agent/workplace/shop_statistics', {
    params,
  });
}

// 获取基础统计数据
export function getStatistics() {
  return axios.get<StatisticsData>('/agent/workplace/statistics');
}

// 获取用户列表
export function getUserList(params: { page: number; limit: number }) {
  return axios.get<UserListResponse>('/agent/user/list', {
    params,
  });
}

// 获取收益折线图数据
export function getReceiveLineChart(params?: any) {
  return axios.get<LineChartData[]>('/agent/workplace/receive_line_chart', {
    params,
  });
}
